package com.ld.cloud.eurekaserver;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("test")
public class HelloEurekaServer {

    private final Logger logger = LoggerFactory.getLogger(HelloEurekaServer.class);
    @Autowired
    private DiscoveryClient discoveryClient;

    @RequestMapping("hello")
    public ResponseEntity helllo(){
        List<String> services = discoveryClient.getServices();
        for (String service:services) {
            logger.info("-----------------service:"+service);
        }
        return new ResponseEntity("Hello,This is user2",HttpStatus.OK);
    }
}
